package io.renren.modules.applicant.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.applicant.entity.ApplicantInforEntity;
import io.renren.modules.applicant.service.ApplicantInforService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 应聘者信息表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2022-01-02 15:44:11
 */
@RestController
@RequestMapping("applicant/applicantinfor")
public class ApplicantInforController {
    @Autowired
    private ApplicantInforService applicantInforService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("applicant:applicantinfor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = applicantInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{applicantId}")
    @RequiresPermissions("applicant:applicantinfor:info")
    public R info(@PathVariable("applicantId") Long applicantId){
        ApplicantInforEntity applicantInfor = applicantInforService.getById(applicantId);

        return R.ok().put("applicantInfor", applicantInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("applicant:applicantinfor:save")
    public R save(@RequestBody ApplicantInforEntity applicantInfor){
        applicantInforService.save(applicantInfor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("applicant:applicantinfor:update")
    public R update(@RequestBody ApplicantInforEntity applicantInfor){
        ValidatorUtils.validateEntity(applicantInfor);
        applicantInforService.updateById(applicantInfor);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("applicant:applicantinfor:delete")
    public R delete(@RequestBody Long[] applicantIds){
        applicantInforService.removeByIds(Arrays.asList(applicantIds));

        return R.ok();
    }

}
